package com.sg.service.base.app.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sg.common.util.CommonFunctionHelper;
import com.sg.dto.base.app.req.*;
import com.sg.entity.OmsTargetObjective;
import com.sg.service.base.app.MOmsTargetObjectiveService;
import com.wicket.okrapp.common.annotations.BanAuto;
import com.wicket.okrapp.common.dto.FieldInfo;
import com.wicket.okrapp.common.exception.BizException;
import com.wicket.okrapp.dal.mapper.mbg.OmsTargetObjectiveMapper;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author ：
 * @version 1.0
 * @since 2022/1/19 15:39
 */
@Service
public class MOmsTargetObjectiveServiceImpl
        extends ServiceImpl<OmsTargetObjectiveMapper, OmsTargetObjective>
        implements MOmsTargetObjectiveService {

    @Autowired
    OmsTargetObjectiveMapper omsTargetObjectiveMapper;

    /**
     * 3-3-03批量查下一级指标列表[2940]
     * gen by moon at 1/5/2023, 6:42:19 PM
     */
    @Trace(operationName = "3-3-03批量查下一级指标列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTargetObjective> batchQueryNextLevelTargetObj(BatchQueryNextLevelTargetObjReq reqDto) {

        try {
            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            reqDto.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
            if (reqDto.getNextLevelTargetObjList() == null || reqDto.getNextLevelTargetObjList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("parent_objective_id", reqDto.getNextLevelTargetObjList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTargetObjective.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByAsc("order_number");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsTargetObjective>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-03批量删指标[2806]
     * gen by moon at 10/16/2022, 7:13:56 AM
     */
    @Trace(operationName = "3-3-03批量删指标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean batchDeleteTargetObj(List<String> reqDto) {

        if (reqDto == null || reqDto.size() == 0) {
            return false;
        }

        return super.removeByIds(reqDto);
    }

    /**
     * 3-3-03修改指标[2792]
     * gen by moon at 10/16/2022, 7:13:55 AM
     */
    @Trace(operationName = "3-3-03修改指标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateTargetObj(OmsTargetObjective omsTargetObjective) {
        omsTargetObjective.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        omsTargetObjective.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        return super.updateById(omsTargetObjective);
    }

    /**
     * 3-3-03删除指标[2741]
     * gen by moon at 10/16/2022, 7:13:54 AM
     */
    @Trace(operationName = "3-3-03删除指标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteTargetObj(String objectiveId) {

        return super.removeById(objectiveId);
    }

    /**
     * 3-3-03查指标详情[2697]
     * gen by moon at 3/30/2023, 12:38:54 PM
     */
    @Trace(operationName = "3-3-03查指标详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public OmsTargetObjective queryTargetObjDetail(QueryTargetObjDetailReq reqDto) {

        try {
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
            queryWrapper.orderByDesc("create_time");
            List<OmsTargetObjective> retList = super.list(queryWrapper);
            if (retList != null && retList.size() > 0) {
                OmsTargetObjective retData = retList.get(0);

                return retData;
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-03查指标列表[2692]
     * gen by moon at 10/16/2022, 7:13:52 AM
     */
    @Trace(operationName = "3-3-03查指标列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTargetObjective> queryTargetObjList(QueryTargetObjListReq reqDto) {

        try {
            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            reqDto.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID

            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTargetObjective.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByAsc("order_number");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsTargetObjective>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-03新增指标[2689]
     * gen by moon at 1/4/2023, 6:11:08 PM
     */
    @Trace(operationName = "3-3-03新增指标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String addTargetObj(OmsTargetObjective omsTargetObjective) {
        omsTargetObjective.setObjectiveId(CommonFunctionHelper.getUid());//DISTRIBUTED_ID
        omsTargetObjective.setObjectiveNumber(CommonFunctionHelper.getUid());//AUTO_GENERATE
        omsTargetObjective.setBatchEndtTime(CommonFunctionHelper.getFutureTime());//FUTURE_CURRENT_TIME
        omsTargetObjective.setIsUpdate("TRUE");
        omsTargetObjective.setUpdateStatus("NEW");
        omsTargetObjective.setIsEditing("TRUE");
        omsTargetObjective.setArchivngType("NOT_ARCHIVE");
        omsTargetObjective.setIsArchive("FALSE");
        omsTargetObjective.setSubjectLifeCycle("EDITING");
        omsTargetObjective.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        omsTargetObjective.setCreateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        omsTargetObjective.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        omsTargetObjective.setCreateInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        omsTargetObjective.setIsValid("FALSE");
        omsTargetObjective.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
        omsTargetObjective.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
        if (super.save(omsTargetObjective)) {
            return omsTargetObjective.getObjectiveId();
        } else {
            return "-1";
        }

    }

    /**
     * 3-3-03批量查指标列表[2203]
     * gen by moon at 10/16/2022, 7:13:51 AM
     */
    @Trace(operationName = "3-3-03批量查指标列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTargetObjective> batchQueryTargetObjList(BatchQueryTargetObjListReq reqDto) {

        try {
            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            reqDto.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
            if (reqDto.getTargetObjList() == null || reqDto.getTargetObjList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("objective_id", reqDto.getTargetObjList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTargetObjective.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByAsc("order_number");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsTargetObjective>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-03批量改指标[2964]
     * gen by moon at 10/16/2022, 7:13:57 AM
     */
    @Trace(operationName = "3-3-03批量改指标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean batchUpdateTargetObj(List<OmsTargetObjective> omsTargetObjective) {

        if (omsTargetObjective == null || omsTargetObjective.size() == 0) {
            return false;
        }
        return super.saveOrUpdateBatch(omsTargetObjective);

    }

    /**
     * 111113-3-03批量查指标标识匹配指标[2981]
     * gen by moon at 11/23/2022, 10:27:59 PM
     */
    @Trace(operationName = "111113-3-03批量查指标标识匹配指标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTargetObjective> batchQueryCodeMatchTargetObj(BatchQueryCodeMatchTargetObjReq reqDto) {

        try {
            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            reqDto.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
            if (reqDto.getTargetObjList() == null || reqDto.getTargetObjList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("objective_code", reqDto.getTargetObjList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTargetObjective.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsTargetObjective>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-03查询指标公共详情[3328]
     * gen by moon at 3/30/2023, 12:38:55 PM
     */
    @Trace(operationName = "3-3-03查询指标公共详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public OmsTargetObjective queryComTargetObjDetail(QueryComTargetObjDetailReq reqDto) {

        try {
            reqDto.setIsValid("FALSE");
            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
            queryWrapper.orderByDesc("create_time");
            List<OmsTargetObjective> retList = super.list(queryWrapper);
            if (retList != null && retList.size() > 0) {
                OmsTargetObjective retData = retList.get(0);

                return retData;
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3查询指标责任主体列表[4069]
     * gen by moon at 10/16/2022, 7:14:00 AM
     */
    @Trace(operationName = "3查询指标责任主体列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTargetObjective> queryTargetObjDutyBodyList() {
        return null; //todo ruizhe dong
    }

    /**
     * 11111查询中层指标分工管理判断[4079]
     * gen by moon at 11/23/2022, 10:28:01 PM
     */
    @Trace(operationName = "11111查询中层指标分工管理判断")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public OmsTargetObjective queryMidTargetObjDivMgtSituationDetail() {
        return null; //todo ruizhe dong
    }

    /**
     * M3-3-03-构造指标验证数据[4247]
     * gen by moon at 10/16/2022, 7:14:01 AM
     */
    @Trace(operationName = "M3-3-03-构造指标验证数据")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String buildSingleTargetObjective(OmsTargetObjective omsTargetObjective) {
        omsTargetObjective.setObjectiveId(CommonFunctionHelper.getUid());//DISTRIBUTED_ID
        omsTargetObjective.setObjectiveNumber(CommonFunctionHelper.getUid());//AUTO_GENERATE
        omsTargetObjective.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        omsTargetObjective.setCreateInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        if (omsTargetObjective != null && omsTargetObjective.getSubjectLifeCycle() != null && omsTargetObjective.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsTargetObjective.setReleaseInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//RELEASED_CURRENT_INDUCTIONID
        }
        if (omsTargetObjective != null && omsTargetObjective.getSubjectLifeCycle() != null && omsTargetObjective.getSubjectLifeCycle().equals("ARCHIVING")) {
            omsTargetObjective.setArchiveInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//ARCHIVE_CURRENT_INDUCTIONID
        }
        omsTargetObjective.setIsValid("FALSE");
        omsTargetObjective.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        omsTargetObjective.setCreateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        if (omsTargetObjective != null && omsTargetObjective.getSubjectLifeCycle() != null && omsTargetObjective.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsTargetObjective.setReleaseTime(CommonFunctionHelper.getCurrentTime());//RELEASE_SYSTEM_CURRENT_TIME
        }
        if (omsTargetObjective != null && omsTargetObjective.getSubjectLifeCycle() != null && omsTargetObjective.getSubjectLifeCycle().equals("ARCHIVING")) {
            omsTargetObjective.setArchiveTime(CommonFunctionHelper.getCurrentTime());//HISTORICAL_ARCHIVING
        }
        omsTargetObjective.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
        omsTargetObjective.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
        if (super.save(omsTargetObjective)) {
            return omsTargetObjective.getObjectiveId();
        } else {
            return "-1";
        }

    }

    /**
     * M3-3-03修改单条指标[4281]
     * gen by moon at 10/16/2022, 7:14:02 AM
     */
    @Trace(operationName = "M3-3-03修改单条指标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateSingleTargetObjective(OmsTargetObjective omsTargetObjective) {

        return super.updateById(omsTargetObjective);
    }

    /**
     * M3-查询多条指标列表[4366]
     * gen by moon at 10/16/2022, 7:14:03 AM
     */
    @Trace(operationName = "M3-查询多条指标列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTargetObjective> queryMultiTargetObjList(QueryMultiTargetObjListReq reqDto) {

        try {
            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();


            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTargetObjective.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsTargetObjective>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * M3-批量删多条指标[4367]
     * gen by moon at 10/16/2022, 7:14:04 AM
     */
    @Trace(operationName = "M3-批量删多条指标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean batchDeleteMultiTargetObj(List<String> reqDto) {

        if (reqDto == null || reqDto.size() == 0) {
            return false;
        }

        return super.removeByIds(reqDto);
    }

    /**
     * M3-查询单条指标详情[4383]
     * gen by moon at 3/30/2023, 12:38:56 PM
     */
    @Trace(operationName = "M3-查询单条指标详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public OmsTargetObjective querySingleTargetObjectiveDetail(QuerySingleTargetObjectiveDetailReq reqDto) {

        try {

            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
            queryWrapper.orderByDesc("create_time");
            List<OmsTargetObjective> retList = super.list(queryWrapper);
            if (retList != null && retList.size() > 0) {
                OmsTargetObjective retData = retList.get(0);

                return retData;
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * M3-3-03删除单条指标[4418]
     * gen by moon at 10/16/2022, 7:14:05 AM
     */
    @Trace(operationName = "M3-3-03删除单条指标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteSingleTargetObjective(String objectiveId) {

        return super.removeById(objectiveId);
    }

    /**
     * M3执行多条指标【循环开始】[4516]
     * gen by moon at 10/16/2022, 7:14:06 AM
     */
    @Trace(operationName = "M3执行多条指标【循环开始】")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public OmsTargetObjective implementMultiTargetObjLoopStart(ImplementMultiTargetObjLoopStartReq reqDto) {

        try {

            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
            queryWrapper.orderByDesc("create_time");
            List<OmsTargetObjective> retList = super.list(queryWrapper);
            if (retList != null && retList.size() > 0) {
                OmsTargetObjective retData = retList.get(0);

                return retData;
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-03查询一级指标列表[4606]
     * gen by moon at 10/19/2022, 10:08:39 PM
     */
    @Trace(operationName = "3-3-03查询一级指标列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTargetObjective> queryFirstTargetObjList(QueryFirstTargetObjListReq reqDto) {

        try {
            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID

            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTargetObjective.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsTargetObjective>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-03批量查询指标列表By指标模板Ids[4934]
     * gen by moon at 10/19/2022, 10:08:40 PM
     */
    @Trace(operationName = "3-3-03批量查询指标列表By指标模板Ids")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTargetObjective> batchQueryTargetObjListByIds(BatchQueryTargetObjListByIdsReq reqDto) {

        try {
            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();

            if (reqDto.getTargetObjList() == null || reqDto.getTargetObjList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("objective_template_id", reqDto.getTargetObjList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTargetObjective.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsTargetObjective>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 页面元素-查询安排的指标详情(管理)  [4948]
     * gen by moon at 10/20/2022, 10:03:07 AM
     */
    @Trace(operationName = "页面元素-查询安排的指标详情(管理)  ")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String queryArrangeTgetObjDetail(OmsTargetObjective omsTargetObjective) {

        if (super.save(omsTargetObjective)) {
            return omsTargetObjective.getObjectiveId();
        } else {
            return "-1";
        }

    }

    /**
     * 页面元素-查询购物车责任主体指标列表(管理) [4950]
     * gen by moon at 10/20/2022, 10:03:07 AM
     */
    @Trace(operationName = "页面元素-查询购物车责任主体指标列表(管理) ")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String queryTargetObjBodyList(OmsTargetObjective omsTargetObjective) {

        if (super.save(omsTargetObjective)) {
            return omsTargetObjective.getObjectiveId();
        } else {
            return "-1";
        }

    }

    /**
     * 页面元素-批量增指标单/不规则被评对象目标周期(管理)[4957]
     * gen by moon at 10/20/2022, 10:03:08 AM
     */
    @Trace(operationName = "页面元素-批量增指标单/不规则被评对象目标周期(管理)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String batchAddTargebjEvaObjTargetCycle(OmsTargetObjective omsTargetObjective) {

        if (super.save(omsTargetObjective)) {
            return omsTargetObjective.getObjectiveId();
        } else {
            return "-1";
        }

    }

    /**
     * M3执行指标测试【循环开始】[4516]
     * gen by moon at 3/30/2023, 12:38:57 PM
     */
    @Trace(operationName = "M3执行指标测试【循环开始】")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public OmsTargetObjective implementTargetTestDataLoopStart(ImplementTargetTestDataLoopStartReq reqDto) {

        try {

            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
            queryWrapper.orderByDesc("create_time");
            List<OmsTargetObjective> retList = super.list(queryWrapper);
            if (retList != null && retList.size() > 0) {
                OmsTargetObjective retData = retList.get(0);

                return retData;
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-03查询指标列表BY标识列表[5194]
     * gen by moon at 3/27/2023, 3:25:20 PM
     */
    @Trace(operationName = "3-3-03查询指标列表BY标识列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTargetObjective> queryTargetObjByCodeList(QueryTargetObjByCodeListReq reqDto) {

        try {
            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();
            // TODO: 2023/5/29 右模糊代码
            if (reqDto.getObjectiveCode() != null) {
                queryWrapper.likeRight("objective_code", reqDto.getObjectiveCode());
                reqDto.setObjectiveCode(null);
            }
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID

            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTargetObjective.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            // TODO: 2023/6/12 特殊排序，手写代码
            queryWrapper.orderByDesc(CommonFunctionHelper.buildSpecOderBy("objective_code"));
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsTargetObjective>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-03批量查询层级排序指标列表[5620]
     * gen by moon at 1/7/2023, 8:39:54 PM
     */
    @Trace(operationName = "3-3-03批量查询层级排序指标列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTargetObjective> batchQueryTargetObjLevel(BatchQueryTargetObjLevelReq reqDto) {

        try {
            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();

            if (reqDto.getTargetObjList() == null || reqDto.getTargetObjList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("objective_id", reqDto.getTargetObjList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTargetObjective.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByAsc("level_number");
            queryWrapper.orderByAsc("order_number");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsTargetObjective>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-06批量查询下一级指标列表By归属父级指标Id[5734]
     * gen by moon at 1/19/2023, 3:49:56 AM
     */
    @Trace(operationName = "3-3-06批量查询下一级指标列表By归属父级指标Id")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTargetObjective> batchQueryNextLevelTargetObjListByIds(BatchQueryNextLevelTargetObjListByIdsReq reqDto) {

        try {
            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            reqDto.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
            if (reqDto.getTargetObjList() == null || reqDto.getTargetObjList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("parent_objective_id", reqDto.getTargetObjList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTargetObjective.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByAsc("order_number");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsTargetObjective>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-03批量查询多层级指标列表ByIds[5820]
     * gen by moon at 2/2/2023, 4:20:37 AM
     */
    @Trace(operationName = "3-3-03批量查询多层级指标列表ByIds")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    @BanAuto
    public List<OmsTargetObjective> batchQueryManyTierTargetObjListByIds(BatchQueryManyTierTargetObjListByIdsReq reqDto) {

        try {
            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            // TODO: 2023/2/9
            if (reqDto.getLevelNumber() != null) {
                queryWrapper.le("level_number", reqDto.getLevelNumber());
                reqDto.setLevelNumber(null);
            }
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            if (reqDto.getTargetObjList() == null || reqDto.getTargetObjList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("objective_id", reqDto.getTargetObjList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTargetObjective.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByAsc("order_number");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsTargetObjective>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-03查询无约束指标详情[5964]
     * gen by moon at 3/30/2023, 12:38:58 PM
     */
    @Trace(operationName = "3-3-03查询无约束指标详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public OmsTargetObjective queryUnrestraintObjtiveDetail(QueryUnrestraintObjtiveDetailReq reqDto) {

        try {
            reqDto.setIsValid("FALSE");
            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
            queryWrapper.orderByDesc("create_time");
            List<OmsTargetObjective> retList = super.list(queryWrapper);
            if (retList != null && retList.size() > 0) {
                OmsTargetObjective retData = retList.get(0);

                return retData;
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * M3批量查询多条指标测试[6222]
     * gen by moon at 4/5/2023, 11:50:32 AM
     */
    @Trace(operationName = "M3批量查询多条指标测试")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTargetObjective> batchQueryMultiTargetObjTestData(BatchQueryMultiTargetObjTestDataReq reqDto) {

        try {
            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            if (reqDto.getTargetObjList() == null || reqDto.getTargetObjList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("objective_id", reqDto.getTargetObjList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTargetObjective.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByDesc("objective_code");
            queryWrapper.orderByDesc("level_number");
            queryWrapper.orderByDesc("order_number");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsTargetObjective>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * M3查询多条指标测试列表[6260]
     * gen by moon at 4/26/2023, 6:52:45 PM
     */
    @Trace(operationName = "M3查询多条指标测试列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTargetObjective> queryMultiTargetObjTestDataList(QueryMultiTargetObjTestDataListReq reqDto) {

        try {
            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");

            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTargetObjective.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsTargetObjective>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-03批量查询责任主体指标排序列表[7481]
     * gen by moon at 10/4/2023, 4:12:17 PM
     */
    @Trace(operationName = "3-3-03批量查询责任主体指标排序列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTargetObjective> batchQueryDutyBodyTargetObjectiveOrderNumList(BatchQueryDutyBodyTargetObjectiveOrderNumListReq reqDto) {

        try {
            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            if (reqDto.getDutyBodyTargetObjectiveOrderNumListList() == null || reqDto.getDutyBodyTargetObjectiveOrderNumListList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("objective_id", reqDto.getDutyBodyTargetObjectiveOrderNumListList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTargetObjective.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByAsc("duty_body_order_num");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsTargetObjective>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-03批量改责任主体指标排序[7485]
     * gen by moon at 10/4/2023, 4:12:18 PM
     */
    @Trace(operationName = "3-3-03批量改责任主体指标排序")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean batchUpdateDutyBodyTargetObjectiveOrderNum(List<OmsTargetObjective> omsTargetObjective) {

        if (omsTargetObjective == null || omsTargetObjective.size() == 0) {
            return false;
        }
        return super.saveOrUpdateBatch(omsTargetObjective);

    }

    /**
     * 3-3-03批量查询评价模板下指标[8920]
     * gen by moon at 3/30/2024, 12:52:41 AM
     */
    @Trace(operationName = "3-3-03批量查询评价模板下指标")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTargetObjective> batchQueryEvaTempObjective(BatchQueryEvaTempObjectiveReq reqDto) {

        try {
            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            if (reqDto.getTargetObjList() == null || reqDto.getTargetObjList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("objective_id", reqDto.getTargetObjList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTargetObjective.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsTargetObjective>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-03查询评价模板指标列表[9333]
     * gen by moon at 4/7/2024, 8:48:47 AM
     */
    @Trace(operationName = "3-3-03查询评价模板指标列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTargetObjective> queryEvaTempObjList(QueryEvaTempObjListReq reqDto) {

        try {
            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();


            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTargetObjective.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsTargetObjective>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-03查询指标详情[9411]
     * gen by moon at 4/19/2024, 8:07:59 PM
     */
    @Trace(operationName = "3-3-03查询指标详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public OmsTargetObjective queryTargetObjectiveDetail(QueryTargetObjectiveDetailReq reqDto) {

        try {

            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
            queryWrapper.orderByDesc("create_time");
            List<OmsTargetObjective> retList = super.list(queryWrapper);
            if (retList != null && retList.size() > 0) {
                OmsTargetObjective retData = retList.get(0);

                return retData;
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-3-03查询无约束指标列表[10154]
     * gen by moon at 8/21/2024, 11:24:37 PM
     */
    @Trace(operationName = "3-3-03查询无约束指标列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTargetObjective> queryUnrestraintObjtiveList(QueryUnrestraintObjtiveListReq reqDto) {

        try {
            QueryWrapper<OmsTargetObjective> queryWrapper = new QueryWrapper<>();


            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTargetObjective.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTargetObjective.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByAsc("objective_code");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsTargetObjective>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }
}
